package com.linxz.wandnroid.presenter;



import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.module.BaseModel;
import com.linxz.framework.base.presenter.BasePresenter;
import com.linxz.wandnroid.appui.view.GankFragView;
import com.linxz.wandnroid.pojo.GankBean;
import com.linxz.wandnroid.pojo.GankMultiBean;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.subjects.PublishSubject;

/**
 * @author Linxz
 * 创建日期：2020年02月28日 23:46
 * version：v4.5.4
 * 描述：
 */
public class GanFragPresenter extends BasePresenter<GankFragView, BaseModel> {

    public GanFragPresenter(GankFragView mView, PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        super(mView, lifecycleSubject);
    }

    @Override
    public BaseModel createModel(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        return new BaseModel(lifecycleSubject);
    }

    public void loadData(List<GankBean> gankBeans){
        List<GankMultiBean> data=new ArrayList<>();
        for (int i=0;i<gankBeans.size();i++){
            GankMultiBean gankMultiBean=new GankMultiBean();
            gankMultiBean.setGankBean(gankBeans.get(i));
            gankMultiBean.setPosition(i);
            data.add(gankMultiBean);
        }
        if (data.size()==0){
            mView.onDataEmpty();
        }else{
            mView.onLoadSuccess(data);
        }
    }
}
